<template>
  <div>
    <el-dialog :visible.sync="addGoodsDialogVisible">
      <el-form :model="reqInfo" width="50%" :rules="goodsFormRules">
        <el-form-item label="名称" prop="goods_name">
          <el-input v-model="reqInfo.goods_name"></el-input>
        </el-form-item>
        <el-form-item label="分类" prop="goods_cat">
          <el-input v-model="reqInfo.goods_cat"></el-input>
        </el-form-item>
        <el-form-item label="价格" prop="goods_price">
          <el-input v-model.number="reqInfo.goods_price"></el-input>
        </el-form-item>
        <el-form-item label="数量" prop="goods_number">
          <el-input v-model.number="reqInfo.goods_number"></el-input>
        </el-form-item>
        <el-form-item label="重量" prop="goods_weight">
          <el-input v-model.number="reqInfo.goods_weight"></el-input>
        </el-form-item>
        <el-form-item label="介绍" prop="goods_introduce">
          <el-input v-model="reqInfo.goods_introduce"></el-input>
        </el-form-item>
      </el-form>

      <template slot="footer">
        <el-button>取消</el-button>
        <el-button type="primary">确认</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'AddGoodsDialog',
  data() {
    return {
      reqInfo: {
        goods_name: '',
        goods_cat: '',
        goods_price: '',
        goods_number: '',
        goods_weight: '',
        goods_introduce: '',
        pics: '',
        attrs: []
      },
      goodsFormRules: {
        goods_name: [
          { requried: true, message: '请输入商品名称', trigger: 'blur' }
        ],
        goods_cat: [
          { requried: true, message: '请输入商品描述', trigger: 'blur' }
        ],
        goods_price: [
          { requried: true, message: '请输入商品价格', trigger: 'blur' }
        ],
        goods_number: [
          { requried: true, message: '请输入商品数量', trigger: 'blur' }
        ],
        goods_weight: [
          { requried: true, message: '请输入商品重量', trigger: 'blur' }
        ],
        goods_introduce: [
          { requried: true, message: '请输入商品介绍', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
    addGoodsDialogVisible: {
      get() {
        return this.$store.state.goods.addGoodsDialogVisible
      },
      set() {
        this.$store.commit('goods/addGoodsDialogVisibleState', false)
      }
    }
  }
}
</script>

<style></style>
